package com.huike.web.controller.contract;

import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.domain.entity.SysUser;
import com.huike.common.core.page.TableDataInfo;
import com.huike.contract.domain.vo.TransferVo;
import com.huike.contract.service.ITbContractService;
import com.huike.contract.service.ITbTransferService;
import com.huike.framework.web.domain.server.Sys;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * @Description TODO
 * @Author YEmeeyo
 * @Date 2023-07-13 9:11
 */
@RestController
@RequestMapping("/transfer")
@Api(tags = "转派相关接口")
@Slf4j
public class TbContractController extends BaseController {
    @Resource
    private ITbTransferService transferService;

    /**
     * 获取转派列表
     * @param user
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("获取转派列表")
    public TableDataInfo list(SysUser user){
        log.info("获取转派列表~");

        startPage();
        List<TransferVo> transferVoList = transferService.list(user);
        return getDataTablePage(transferVoList);
    }

    /**
     * 转派处理
     * @param type
     * @param userId
     * @param transferUserId
     * @return
     */
    @PutMapping("/assignment/{type}/{userId}/{transferUserId}")
    @ApiOperation("转派处理")
    public AjaxResult assignment(@PathVariable String type, @PathVariable Long userId, @PathVariable Long transferUserId){

        transferService.assignment(type, userId, transferUserId);
        Map<String, Object> resultMap = new HashMap<>();

        resultMap.put("flag",true);
        resultMap.put("msg",null);
        return AjaxResult.success(resultMap);
    }
}
